package com.cfs.svcimpl.sys;

import java.util.LinkedList;
import java.util.List;

import com.cfs.dao.sys.DictDao;
import com.cfs.svc.sys.DictService;
import com.cfs.po.sys.Dict;


public class DictServiceImpl implements DictService {

	private DictDao dao = null;
	public void setDao(DictDao dao){
		this.dao = dao;
	}

	@Override
	public Dict getByName(String name) {
//		return DictDao.getByName(name);
		return dao.getByName(name);
	}


	@Override
	public Dict[] getArr(String flds) {
//		return DictionaryMap.get(new String[]{flds})[0];
		return new Dict[]{getByName("")};
	}

	@Override
	public List<Dict> getList(String flds) {
		List<Dict> list = new LinkedList<Dict>();
		list.add(getByName("aa") );
		list.add(getByName("aa") );
		return list;
	}

	@Override
	public int addDict(Dict d) {
//		System.out.println("name:" + d.getName() + " size" + d.getKvs());
		
		return dao.add(d);
	}

	@Override
	public int updateDict(Dict d) {
		return dao.update(d);
	}

	/**
	 * 字典名称列表
	 */
	@Override
	public Dict[] listNames() {
		List<String> sl = dao.listNames();
		Dict[] sa = new Dict[sl.size()];

		int x = 0;
		for(String s : sl){
			Dict d = new Dict();
			d.setName(s);
			sa[x++] = d;
		}

		return sa;
	}

	@Override
	public int deleteByName(String name) {
//		System.out.println("deleteByName: " + name);
		return dao.deleteByName(name);
	}

	@Override
	public Dict getCascByName(String name) {
		// TODO Auto-generated method stub
		return dao.getCascByName(name);
	}
	
	@Override
	public Dict[] listCHNames() {
		// TODO Auto-generated method stub
		return dao.listCHName();
	}


}
